#include<bits/stdc++.h>
using namespace std;

typedef struct LinkedList
{
	int data;
	LinkedList* next;
}LL;

int a[210000], n;

void InitLL(LL* &x)
{
	x = new LL;
	x->next = NULL;
	LL *r, *s;
	s = x;
	int i = 0;
	while(i < n)
	{
		r = new LL;
		r->data = a[i++];
		s->next = r;
		s = r;
	}
	s->next = NULL;
}

void delK(LL* &y, int k)
{
	LL* x = y;
	while(x->next != NULL)
	{
		LL* t;
		t = new LL;
		if(x->next->data == k)
		{
			t = x->next;
			x->next = t->next;
			delete t;
		}
		else
			x = x->next;
	}
}

void Print(LL* x)
{
	while(x->next != NULL)
	{
		x = x->next;
		cout<<x->data<<" ";
	}
}

int main()
{
	LL* L;
	cin>>n;
	for(int i = 0;i < n;i++)
		cin>>a[i];
	int k;
	cin>>k;
	InitLL(L);
	delK(L, k);
	Print(L);
    return 0;
}

